package p2.genetic;

import generic.genetic.chromosome.Chromosome;
import generic.genetic.chromosome.PermutationChromosome;

public class HospitalDistributionChromosome extends PermutationChromosome{

	private int flow[][];
	private int distance[][];
		
	public HospitalDistributionChromosome(int flow[][], int distance[][]) {
		
		super(flow[0].length);
		this.flow = flow;
		this.distance = distance;
		
	}

	public HospitalDistributionChromosome(HospitalDistributionChromosome hdc) {
		
		super(hdc);
		this.flow = hdc.flow;
		this.distance = hdc.distance;
	}
		
	@Override
	public float evaluate() {
		
		int value = 0;
		for (int i=0;i<nGenes;i++){
			for (int j=0;j<nGenes;j++){
				value += flow[i][j]*distance[permutation[i]][permutation[j]];
			}
		}
		return value;
	}

	@Override
	public Chromosome getCopy() {
		return new HospitalDistributionChromosome(this);
	}

}
